package com.lee.mysql.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import java.util.Base64;

/**
 * Base64/MD5加密/解密
 * @author Lee
 */
public class DecryptUtil {

    /**
     * Base64加密
     */
    public static String enCodeB64(String password){
        //获取加密对象
        Base64.Encoder encoder = Base64.getEncoder();
        //加密
        return new String(encoder.encode(password.getBytes()));
    }

    /**
     * Base64解密
     */
    public static String deCodeB64(String password){
        //获取解密对象
        Base64.Decoder decoder = Base64.getDecoder();
        //解密
        return new String(decoder.decode(password.getBytes()));
    }


    /**
     * MD5加密
     */
    public static String enCodeMD5(String password, String salt){
        SimpleHash sh = new SimpleHash("MD5",password,salt,1);
        return sh.toHex();
    }



    public static void main(String[] args) {
        System.out.println(enCodeB64("1111"));
    }


}